<template>
	<view class="down">
		<view class="tip" v-if="tip">
			<image src="../../static/images/arrow.png" mode="" class="arrow-img"></image>
			<view class="text">请点击右上角的</view>
			<view class="text impotant">...</view>
			<view class="text">在弹出的菜单中选择</view>
			<view class="text impotant">在浏览器中打开</view>
			<view class="text">即可下载</view>
		</view>
		<view class="downlogo" :style="'background-image: url('+logoUrl+');'"></view>

		<button type="default" class="btn" @click="Download">立即下载{{version?"("+version+")":""}}</button>
		<view class="uni-p-b-98"></view>

	</view>

</template>

<script>
	// import {
	// 	getLogo
	// } from "@/api/public";
	import {
		HTTP_REQUEST_URL
	} from '@/config/app';
	import {
		shareAPP
	} from "@/api/api.js";
	export default {
		components: {

		},
		data() {
			return {
				isWachat: false,
				version: "",
				downloadurl: '',
				logoUrl: "",
				tip:false

			}

		},
		onLoad() {
			this.getInfo();

		},
		mounted: function() {
			// this.getCode();
			// this.getLogoImage();
		},
		methods: {

			// async getLogoImage() {
			// 	let that = this;
			// 	getLogo(2).then(res => {
			// 		that.logoUrl = res.data.app_logo;
			// 	});
			// },
			getInfo() {
				shareAPP().then(res => {
					console.log(res);
					if (res && res.data) {
						var data = res.data.android;
						this.version = data.version;
						this.downloadurl = data.downloadurl;
						this.logoUrl = res.data.app_logo;
					}

				});
			},
			is_weixin() {
			  var ua = navigator.userAgent.toLowerCase();
			  if (ua.match(/MicroMessenger/i) == "micromessenger") {
				return true;
			  } else {
				return false;
			  }
			},
			Download: function() {
				var isWeixin = this.is_weixin();
				if(isWeixin){
					// 在微信浏览器提示
					this.tip=true
					return
				}
				
				// #ifndef H5
				return uni.showModal({
					title: "温馨提示",
					content: "应用不支持，请在浏览器中访问~",
					showCancel: false
				})
				// #endif

				// #ifdef H5
				if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
					return uni.showModal({
						title: "系统提示",
						content: "APP只支持安卓版本，苹果系统不支持~",
						showCancel: false
					})
				}

				if (this.$wechat.isWeixin()) {
					// this.isWachat = true;
					return uni.showModal({
						title: "温馨提示",
						content: "请在浏览器中访问~",
						showCancel: false
					})
				}

				// #endif

				if (!this.downloadurl) {
					return uni.showModal({
						title: "系统提示",
						content: "没有获取到app相关信息~",
						showCancel: false
					})
				}

				location.href = this.downloadurl;
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100vh;
		position: relative;
	}

	.down {
		width: 100vw;
		height: 100vh;
		overflow: hidden;
		position: relative;
	}

	.downlogo {
		width: 100%;
		height: 100%;
		background-size: cover;
		background-repeat: no-repeat;
		background-position: center;
	}

	.llqdk {
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;
		width: 100%;
		height: 100%;
	}

	.llqdk image {
		width: 100%;
		height: 100%;
	}

	.btn {
		display: flex;
		align-items: center;
		justify-content: center;
		width: auto;
		padding: 0 85rpx;
		white-space: nowrap;
		height: 92rpx;
		background-image: linear-gradient(198deg,
				#0bc4fa 0%,
				#2676e4 100%),
			linear-gradient(#1c67f3,
				#1c67f3);
		background-blend-mode: normal,
			normal;
		box-shadow: 0px 10rpx 29rpx 0px rgba(0, 0, 0, 0.2);
		border-radius: 46rpx;
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 100rpx;
		color: #fff;
		font-size: 45rpx;
	}
	
	.tip{
		position: absolute;
		width: 100%;
		height: 100%;
		background: rgba(0,0,0,.8);
		z-index: 999;
		.arrow-img{
			width: 200rpx;
			height: 200rpx;
			position: absolute;
			right: 1px;
			top: 60rpx;
		}
		.text{
			text-align: center;
			line-height: 30px;
			color: #fff;
			font-size: 20px;
			position: relative;
			top: 20%;
		}
		.impotant{
			color: #337e23;
		}
	}
</style>
